package com.example.gokchinesefoodmappcdev.util;

import cn.hutool.cache.impl.TimedCache;

/**
 * @Description:缓存工具类
 * @author:chen jianbin
 * @date: 2022/11/25
 */
public class TimeCacheUtil {
    private static final TimedCache<String, String> timedCache = cn.hutool.cache.CacheUtil.newTimedCache(1000);

    static {
        //每5ms检查一次过期
//        timedCache.schedulePrune(5);
    }

    /**
     *将值存入缓存
     * @param key
     * @param value
     * @param timeout 过期时间 单位ms
     */
    public static void put(String key,String value,Integer timeout){
        timedCache.put(key,value,timeout);
    }

    /**
     * 获取缓存中的值
     * @param key
     * @return
     */
    public static String get(String key){
        return timedCache.get(key);
    }

    public static void remove(String key){
        timedCache.remove(key);
    }


}
